#!/usr/bin/env python3
#-*-encoding:utf-8-*-

import os

#清空控制台
def clear():
    print("\033c",end="")

# 二分查找法
#运行时间 O(log N)
def binary_search(list,item):
    low=0
    hight = len(list) - 1
    while low <= hight:
        mid = (low + hight) // 2 #检查中间元素
        guess = list[mid]
        #print(mid)
        if guess == item:
            return mid
        if guess > item:
            hight = mid - 1
        else:
            low = mid + 1
    return None

# ----------------------------------------------
clear()  #清屏
mlist = [1,3,5,7,9]
print(binary_search(mlist,7))


